package com.example.home.volunteer_service;

import android.os.Bundle;
import android.view.MenuItem;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.example.home.R;
import com.example.home.volunteer_service.fragment.ActivityFragment;
import com.example.home.volunteer_service.fragment.MeActivityFragment;
import com.example.home.volunteer_service.fragment.ServiceMainFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class VolunteerServiceMainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_volunteer_service_main);
        BottomNavigationView botview = findViewById(R.id.botview);

        ActivityFragment activityFragment = new ActivityFragment();
        MeActivityFragment meActivityFragment = new MeActivityFragment();
        ServiceMainFragment serviceMainFragment = new ServiceMainFragment();
        getSupportFragmentManager().beginTransaction().replace(R.id.YeMian,activityFragment).commit();
        botview.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()){
                    case R.id.first:
                        getSupportFragmentManager().beginTransaction().replace(R.id.YeMian,activityFragment).commit();
                        break;
                    case R.id.activi:
                        getSupportFragmentManager().beginTransaction().replace(R.id.YeMian,meActivityFragment).commit();
                        break;
                    case R.id.meactivi:
                        getSupportFragmentManager().beginTransaction().replace(R.id.YeMian,serviceMainFragment).commit();
                        break;
                }
                return true;
            }
        });
    }
}